package com.manlitech.cloudboot.baseboot.prox;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.Proxy;

public class ProxMain {
    public static void main(String[] args) {
        Class<A> aClass = A.class;
        Class<?>[] interfaces = aClass.getInterfaces();
        if (interfaces.length == 0) {
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(A.class);
            enhancer.setCallback(new CglibProx());
            A a = (A) enhancer.create();
            a.say();
        }else {
            JdkProx jdkProx = new JdkProx(new A());
            User user = (User) Proxy.newProxyInstance(aClass.getClassLoader(), interfaces, jdkProx);
            user.say();
        }
    }
}
